package org.ruslan.kolobok;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;

public class Utils {

	private Utils() {
		// utility
	}
	
	public static Rectangle createRectangle(TextureRegion textureRegion) {
		return new Rectangle(textureRegion.getRegionX(), textureRegion.getRegionY(), textureRegion.getRegionWidth(),
				textureRegion.getRegionHeight());
	}
	
	public static void drawTextureRegion(SpriteBatch batcher, TextureRegion region, Rectangle rect) {
		drawTextureRegion(batcher, region, 0, 0, rect);
	}

	public static void drawTextureRegion(SpriteBatch batcher, TextureRegion region, int x, int y, Rectangle rect) {
		batcher.draw(region, x + rect.x, y + rect.y, rect.width, rect.height);
	}
	
	public static void drawRect(ShapeRenderer shapeRenderer, int x, int y, Rectangle rectangle) {
		shapeRenderer.rect(x + rectangle.x, y + rectangle.y, rectangle.width, rectangle.height);
	}
	
	public static void drawRect(ShapeRenderer shapeRenderer, Rectangle rectangle, Color color) {
		drawRect(shapeRenderer, 0, 0, rectangle, color);
	}

	private static void drawRect(ShapeRenderer shapeRenderer, int x, int y, Rectangle rectangle, Color color) {
		shapeRenderer.setColor(color);
		drawRect(shapeRenderer, x, y, rectangle);
	}
}
